/* /////////////////////////////////////////////////////////////////////////////
 * File:        sample.d
 *
 * Purpose:     $B?'!9<B83!D$h$/=q$-49$o$k0UL#$N$J$$%3!<%I$G$9!#(B
 *
 * Created      4th June 2007
 * Updated:     6th June 2007
 *
 * www:         http://
 *
 * Copyright (C) 2007 by Yasunobu Imamura
 *
 * This software is provided 'as-is', without any express or implied warranty.
 * In no event will the authors be held liable for any damages arising from the
 * use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 *
 * 1. The origin of this software must not be misrepresented; you must not claim
 * that you wrote the original software. If you use this software in a product,
 * an acknowledgment in the product documentation would be appreciated but is
 * not required.
 *
 * 2. Altered source versions must be plainly marked as such, and must not be
 * misrepresented as being the original software.
 *
 * 3. This notice may not be removed or altered from any source distribution. 
 *
 * ////////////////////////////////////////////////////////////////////////// */

module sample;

private import std.stdio;
private import std.stream;
private import gtree.all;

class sample : ISerializable
{
	int a;
	short b;
	byte c;
	void serialize(Serializer s)
	{
		s.serialize(&a, &b, &c);
	}
}

/*

void main()
{
	scope s = new OutputSerializer("output.dat");
	sample[4] m;

	for(int i=0; i<4; ++i)
	{
		writefln(i);
		m[i] = new sample;
		m[i].a = i+10000;
		m[i].b = i+1000;
		m[i].c = i+100;
	}
	writefln("Hello, world!");
	s.serialize(&m, &m);
	writefln("Hello, world!");
}

*/

void main()
{
/*
	alias StringFeature.StringFeature!(char, StringFeature.StringEditDistanceNorm) FtrType;
	FtrType colun = new FtrType("colun");
	FtrType column = new FtrType("column");

	writefln(colun.distance(column));

/*/
	alias StringFeature!(char, StringEditDistanceNorm) FtrType;
	alias NaiveTree!(FtrType) MyTree;
	alias Query!(FtrType) MyQuery;

	MyTree tree = new MyTree;

	{
		scope file = new File("dic.txt");
		foreach(char[] line; file)
		{
			FtrType f = new FtrType(line);
			tree.insert(f);
		}
	}

	writef("Please Input: ");
	char[] str = readln();
	while(str.length && str[$-1]=='\n')
	{
		str.length = str.length - 1;
	}

	FtrType q_ftr = new FtrType(str);
	MyQuery query = new MyQuery(q_ftr, 100, 100);

	tree.metricSearch(query);
	query.print();
//*/
}
